import java.util.Arrays;
import java.util.Scanner;

public class Problem {
    public static void main1(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int t=scanner.nextInt();
        while (t-->0){
            int n=scanner.nextInt();
            int sum=0;
            while (n>0){
                sum+=n%10;
                n/=10;
            }
            System.out.println(sum);
        }
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt(); // 读取测试用例的数量

        for (int i = 0; i < t; i++) {
            int a1 = scanner.nextInt();
            int a2 = scanner.nextInt();
            int b1 = scanner.nextInt();
            int b2 = scanner.nextInt();

            int result = calculateWaysToWin(a1, a2, b1, b2);
            System.out.println(result);
        }
        scanner.close();
    }

    private static int calculateWaysToWin(int a1, int a2, int b1, int b2) {
        int[][] comparisons = {
                {a1, b1},
                {a2, b2},
                {a1, b2},
                {a2, b1},
                {a2, b2},
                {a1, b1},
                {a2, b1},
                {a1, b2}
        };
        int suneetWins = 0;
        int slavicWins = 0;
        int waysToWin = 0;
        for (int i = 0; i < comparisons.length; i++) {
            if (comparisons[i][0] > comparisons[i][1]) {
                suneetWins++;
            }
            else if(comparisons[i][0] < comparisons[i][1]){
                slavicWins++;
            }
            if(i%2==1){
                if(suneetWins>slavicWins){
                    waysToWin++;
                }
                suneetWins=0;
                slavicWins=0;
            }
        }
        return waysToWin;
    }
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt(); // 读取测试用例的数量
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt(); // 读取任务的数量
            int s = scanner.nextInt(); // 读取淋浴所需的时间
            int m = scanner.nextInt(); // 读取一天的总时间

            // 读取所有任务并将其转换为数组
            int[][] tasks = new int[n][2];
            for (int j = 0; j < n; j++) {
                tasks[j][0] = scanner.nextInt(); // 任务开始时间
                tasks[j][1] = scanner.nextInt(); // 任务结束时间
            }
            String result = canShower(tasks, s, m) ? "YES" : "NO";
            System.out.println(result);
        }
        scanner.close();
    }
    private static boolean canShower(int[][] tasks, int s, int m) {
        Arrays.sort(tasks, (a, b) -> a[0] - b[0]);
        int lastTaskEnd = 0;
        for (int[] task : tasks) {
            if (task[0] - lastTaskEnd >= s) {
                return true;
            }
            lastTaskEnd = task[1];
        }
        if (m - lastTaskEnd >= s) {
            return true;
        }
        return false;
    }
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int T = scanner.nextInt();

            while (T-->0){
                String s = scanner.next();
                String t = scanner.next();

                boolean[] used = new boolean[t.length()];
                StringBuilder result = new StringBuilder(s.length());

                boolean possible = true;
                int i = 0,j = 0;
                for (i = 0, j = 0; i < s.length() && possible; i++) {
                    char c = s.charAt(i);
                    if (c != '?') {
                        if (j < t.length() && c == t.charAt(j)) {
                            result.append(c);
                            j++;
                        } else {
                            result.append(c);
                        }
                    } else {
                        if (j < t.length()) {
                            result.append(t.charAt(j));
                            j++;
                        } else {
                            result.append(c);
                        }
                    }
                }

                if (j <= t.length()) {
                    for (int k = j; k < t.length(); k++) {
                        if (!used[k]) {
                            possible = false;
                            break;
                        }
                    }
                }

                if (possible) {
                    System.out.println("YES");
                    String str=result.toString();
                    char[] arr=str.toCharArray();
                    for (int k = 0; k < str.length(); k++) {
                        if(arr[k]=='?'){
                            arr[k]='a';
                        }
                    }
                    StringBuilder stringBuilder=new StringBuilder(s.length());
                    for (int k = 0; k < arr.length; k++) {
                        stringBuilder.append(arr[k]);
                    }
                    System.out.println(stringBuilder.toString());
                } else {
                    System.out.println("NO");
                }
            }
            scanner.close();
        }
    }

